package com.grass.appointment.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.grass.appointment.C2694R;
import java.util.Objects;

public class UnLockDialog extends DialogFragment implements View.OnClickListener {
    private String title;
    private TextView tvPositive;
    private TextView tvTitle;
    private String txtPositive;
    private UnlockInterface unlockInterface;

    public interface UnlockInterface {
        void onCommitClick();
    }

    public static UnLockDialog newInstance(String str) {
        Bundle bundle = new Bundle();
        UnLockDialog unLockDialog = new UnLockDialog();
        bundle.putString("perice", str);
        unLockDialog.setArguments(bundle);
        return unLockDialog;
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        return layoutInflater.inflate(C2694R.C2699layout.dialog_unlock_layout, viewGroup, false);
    }

    @Override // androidx.fragment.app.DialogFragment
    public Dialog onCreateDialog(Bundle bundle) {
        DialogC27971 r3 = new Dialog((Context) Objects.requireNonNull(getActivity()), C2694R.C2701style.MyDialogStyle) {
            /* class com.grass.appointment.dialog.UnLockDialog.DialogC27971 */

            public void onBackPressed() {
                dismiss();
            }
        };
        r3.setCancelable(true);
        r3.setCanceledOnTouchOutside(true);
        return r3;
    }

    @Override // androidx.fragment.app.Fragment
    public void onViewCreated(View view, Bundle bundle) {
        if (getArguments() != null) {
            initView(view, getArguments().getString("perice"));
        }
        super.onViewCreated(view, bundle);
    }

    @Override // androidx.fragment.app.Fragment, androidx.fragment.app.DialogFragment
    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        this.tvTitle.setText(this.title);
        this.tvPositive.setText(this.txtPositive);
    }

    private void initView(View view, String str) {
        TextView textView = (TextView) view.findViewById(C2694R.C2697id.tv_perice);
        if (!TextUtils.isEmpty(str)) {
            textView.setText(str);
        }
        this.tvTitle = (TextView) view.findViewById(C2694R.C2697id.tv_title);
        TextView textView2 = (TextView) view.findViewById(C2694R.C2697id.tv_positive);
        this.tvPositive = textView2;
        textView2.setOnClickListener(this);
        view.findViewById(C2694R.C2697id.tv_negative).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.appointment.dialog.UnLockDialog.View$OnClickListenerC27982 */

            public void onClick(View view) {
                UnLockDialog.this.dismiss();
            }
        });
    }

    public void setContent(String str, String str2) {
        this.title = str;
        this.txtPositive = str2;
    }

    public void onClick(View view) {
        UnlockInterface unlockInterface2;
        dismiss();
        if (view.getId() == C2694R.C2697id.tv_positive && (unlockInterface2 = this.unlockInterface) != null) {
            unlockInterface2.onCommitClick();
        }
    }

    @Override // androidx.fragment.app.DialogFragment
    public void show(FragmentManager fragmentManager, String str) {
        FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
        beginTransaction.add(this, str);
        beginTransaction.commitAllowingStateLoss();
    }

    public void setUnlockInterface(UnlockInterface unlockInterface2) {
        this.unlockInterface = unlockInterface2;
    }

    @Override // androidx.fragment.app.DialogFragment
    public void dismiss() {
        dismissAllowingStateLoss();
    }
}
